﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage/MasterPage.Master" AutoEventWireup="true" CodeBehind="BGM_Mas_Option_1.aspx.cs" Inherits="KPIS.GERP.GBMS.APP_UI.BGM_Mas_Option_1" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<%@ Register src="../Controls/TreeView/TreeViewOption.ascx" tagname="TreeViewOption" tagprefix="uc2" %>
<%@ Register src="../Controls/Panel/UserPanel.ascx" tagname="UserPanel" tagprefix="uc3" %>
<%@ Register src="../Controls/Panel/CommandPanel.ascx" tagname="CommandPanel" tagprefix="uc4" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <LINK REL="StyleSheet" HREF="../../Styles/StyleSheet.css" TYPE="text/css">

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None"  > 
</telerik:RadAjaxLoadingPanel>

<telerik:RadAjaxManager runat="server" ID="RadManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
    <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="CmdCtrl">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelGrid" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="PanelList" LoadingPanelID="RadAjaxLoadingPanel1"/>            
                    <telerik:AjaxUpdatedControl ControlID="panelTree" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="ddlYear" LoadingPanelID="RadAjaxLoadingPanel1"/>                                               
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="Grid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelGrid" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="PanelList" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="CmdCtrl" LoadingPanelID="RadAjaxLoadingPanel1"/>                                               
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ddlYear">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelGrid" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <%--<telerik:AjaxUpdatedControl ControlID="PanelList" LoadingPanelID="RadAjaxLoadingPanel1"/>
                    <telerik:AjaxUpdatedControl ControlID="CmdCtrl" LoadingPanelID="RadAjaxLoadingPanel1"/>--%>                                               
                </UpdatedControls>
            </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
function nodeClicking(sender, args)
            {
                var comboBox = $find("<%= cbParent.ClientID %>");

                var node = args.get_node()

                comboBox.set_text(node.get_text());

                comboBox.trackChanges();
                comboBox.get_items().getItem(0).set_value(node.get_text());
                comboBox.commitChanges();

                comboBox.hideDropDown();
            }

            function StopPropagation(e)
            {
                if(!e)
                {
                    e = window.event;
                }

                e.cancelBubble = true;
            }
            
            function OnClientDropDownOpenedHandler(sender, eventArgs)
            {
                var tree = sender.get_items().getItem(0).findControl("tParent");
                var selectedNode = tree.get_selectedNode();
                if (selectedNode)
                {
                    selectedNode.scrollIntoView();
                }
            }


            </script>
        </telerik:RadCodeBlock>

<div class="defaultFont">

<asp:Label ID="hdSeq" Visible="false" runat="server" Text="" ></asp:Label>
<asp:Label ID="hdCode" Visible="false" runat="server" Text="" ></asp:Label>

<table style="width: 980px; height: 100%">
    <tr>
    <%--<td width="274px" valign="top">
        <uc3:UserPanel ID="UserCtrl" runat="server" />
    </td>--%>
    <td valign = "top">
        <uc4:CommandPanel ID="CmdCtrl" runat="server" />
    </td>
    </tr>
    <tr>
    <td valign = "top" colspan="2">
        <div class="Background980">
            <div class="BackgroundBottom980">
                <br />
                <table width="100%" bgcolor="#7DA5E0" style="padding: 5px; color: #FFFFFF; font-weight: bold;">
                    <tr align="left" valign="top" >
                        <td width="200px">
                            <asp:Label ID="lblHeader" runat="server"></asp:Label>
                        </td>
                        <td>
                            <telerik:RadComboBox ID="ddlYear" runat="server" Width="100px" 
                                CssClass="textbox-string" 
                                OnSelectedIndexChanged="ddlYear_SelectedIndexChanged" AutoPostBack="True">
                                <Items>
                                </Items>
                            </telerik:RadComboBox>
                        </td>
                    </tr>
                </table>
                <asp:Panel runat="server" ID="panelList" Height="360px" ScrollBars="Auto" visible="false">
                    <ul class="formList" id="Ul1">      
                        <li><table><tr><td style="width: 200px">รหัส :</td><td><asp:Label runat="server" ID="lbCode" AssociatedControlID="txtCode"></asp:Label>
                            <asp:TextBox ID="txtCode" runat="server" Visible="false" Width="150px" ValidationGroup="1"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                ControlToValidate="txtCode" ErrorMessage="*" SetFocusOnError="True" 
                                ValidationGroup="1"></asp:RequiredFieldValidator></td></tr></table>
                        </li>
                        <li><table><tr><td style="width: 200px">ชื่อ<asp:Literal runat="server" ID="lbConfigName"></asp:Literal> :</td><td><asp:Label runat="server" ID="lbName" AssociatedControlID="txtName"></asp:Label>
                        <asp:TextBox ID="txtName" runat="server" Visible="false" Width="300px" ValidationGroup="1"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                ControlToValidate="txtName" ErrorMessage="*" SetFocusOnError="True" 
                                ValidationGroup="1"></asp:RequiredFieldValidator></td></tr></table>
                        </li>
                        <li><table><tr><td valign="top" style="width: 200px">คำอธิบาย :</td><td><asp:Label runat="server" ID="lbDescr" AssociatedControlID="txtDescr" ></asp:Label>
                        <asp:TextBox ID="txtDescr" runat="server" Visible="false" TextMode="MultiLine" Height="100" Width="300px"></asp:TextBox>
                        </td></tr></table>
                        </li>
                            <asp:Panel runat="server" ID="pnParent">
                         <li>
                           <table>
                                <tr>
                                    <td valign="top" style="width: 200px">
                                        อยู่ภายใต้<asp:Literal runat="server" ID="lbConfigParent"></asp:Literal> :</td>
                                       <td>
                                        <asp:Label ID="lbParent" runat="server" AssociatedControlID="cbParent"></asp:Label>
                                         <telerik:RadComboBox ID="cbParent" Runat="server"   Width="300px" Height="200px" OnClientDropDownOpened="OnClientDropDownOpenedHandler">
                                                <ItemTemplate>
                                                    <telerik:RadTreeView ID="tParent" runat="server"
                                                    DataFieldID="ID" DataValueField="ValueField" DataFieldParentID="Parent"
                                                    DataTextField="TextField" OnClientNodeClicking="nodeClicking">
                                                        <DataBindings>
                                                            <telerik:RadTreeNodeBinding />
                                                        </DataBindings>
                                                    </telerik:RadTreeView>
                                                </ItemTemplate>
                                                <Items>
                                                    <telerik:RadComboBoxItem />
                                                </Items>
                                         </telerik:RadComboBox>
                                    </td>
                                </tr>
                            </table>
                        </li>
                            </asp:Panel>
                        <li class="lastListItem">
                        </li>
                    </ul>
                </asp:Panel>
                <asp:Panel ID="panelGrid" runat="server" Height="340px" ScrollBars="Auto" Visible="true">
                    <br />
                    <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="Grid" runat="server" AllowFilteringByColumn="true"
                        AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" EnableAJAX="True" OnItemCommand="Grid_ItemCommand"
                        GridLines="None" PageSize="8" ShowStatusBar="false">
                        <MasterTableView AllowMultiColumnSorting="true" DataKeyNames="Sequence" ClientDataKeyNames="Sequence"
                            Width="100%">
                            <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                            <Columns>
                                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" ItemStyle-Width="30px"
                                 HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                                 </telerik:GridClientSelectColumn>
                                <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                    CurrentFilterFunction="Contains" DataField="Code" 
                                    FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                    HeaderText="รหัส" ItemStyle-Width="80px" ShowFilterIcon="false" ItemStyle-HorizontalAlign="Left"
                                    UniqueName="Code">
                                </telerik:GridBoundColumn>                              
                                 <telerik:GridTemplateColumn AutoPostBackOnFilter="true" 
                                    CurrentFilterFunction="Contains" DataField="Name" FilterControlWidth="100%" 
                                    HeaderStyle-HorizontalAlign="Center" Visible="false"
                                    ShowFilterIcon="false">
                                    <ItemTemplate>
                                        <asp:Label ID="targetSequence" runat="server" Text='<%# Eval("Sequence") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" />
                                </telerik:GridTemplateColumn>                                
                                <telerik:GridTemplateColumn AutoPostBackOnFilter="true" 
                                    CurrentFilterFunction="Contains" DataField="Name" FilterControlWidth="100%" 
                                    HeaderStyle-HorizontalAlign="Center"
                                    ShowFilterIcon="false" ItemStyle-Width="170px" UniqueName="Name">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="targetControl" runat="server" CommandName="TargetClick"
                                            Text='<%# Eval("Name") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" />
                                </telerik:GridTemplateColumn>  
                                <telerik:GridBoundColumn AutoPostBackOnFilter="true" 
                                    CurrentFilterFunction="Contains" DataField="Description" 
                                    FilterControlWidth="100%" HeaderStyle-HorizontalAlign="Center" 
                                    HeaderText="คำอธิบาย" ShowFilterIcon="false" UniqueName="Description">
                                </telerik:GridBoundColumn>
                           </Columns>
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true" >
                            <Selecting AllowRowSelect="True" />
                            <ClientEvents />
                        </ClientSettings>
                    </telerik:RadGrid>
                </asp:Panel>
            </div>
        </div>
        
    </td>
    </tr>
</table>
</div>
</asp:Content>
